package com.hmall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticSearchConfig {

    private static final String url="http://192.168.108.100:9200";
    @Bean
    public RestHighLevelClient restHighLevelClient() {
        //es服务器的地址
        HttpHost httpHost = HttpHost.create(url);
        RestClientBuilder builder = RestClient.builder(httpHost);
        return new RestHighLevelClient(builder);


    }


}
